//
//  YYEEmoticonCollectionView.swift
//  weibo14
//
//  Created by mac on 16/3/13.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

class YYEEmoticonCollectionView: UICollectionView {

    override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
        super.init(frame: frame, collectionViewLayout: layout)
        setupUI()
    }

    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI() {
        // 隐藏滚动条
        self.showsHorizontalScrollIndicator = false
        self.pagingEnabled = true
        self.bounces = false
        self.backgroundColor = UIColor.clearColor()
    }
    
    override func layoutSubviews() {
        
        // 1. 取layout
        let layout = self.collectionViewLayout as! UICollectionViewFlowLayout
        // 2. 设置条目大小
        layout.itemSize = self.bounds.size
        // 3. 间距
        layout.minimumInteritemSpacing = 0
        layout.minimumLineSpacing = 0
        // 4. 设置滚动方向
        layout.scrollDirection = .Horizontal
        
        super.layoutSubviews()
    }
}
